library _;

import 'package:chewie/chewie.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/Const/IFinal.dart';
import 'package:flutter_app/Extension/String++.dart';
import 'package:flutter_app/Model/CartModel.dart';
import 'package:flutter_app/Model/ProductModel.dart';
import 'package:flutter_app/Page/Cart/Main/main.dart';
import 'package:flutter_app/Page/Home/OrderConfirm/main.dart';
import 'package:flutter_app/Page/Home/Search/main.dart';
import 'package:flutter_app/Page/Main/Other/ShowPicture/main.dart';
import 'package:flutter_app/Page/Message/Chat/main.dart';
import 'package:flutter_app/Util/YOSS/YOSS.dart';
import 'package:flutter_app/View/MyLoader.dart';
import 'package:flutter_app/View/MyNumPicker.dart';
import 'package:flutter_app/View/MySupportViews.dart';
import 'package:flutter_app/View/MyViews.dart';
import 'package:flutter_yfree/YFree.dart';
import 'package:sharesdk_plugin/sharesdk_plugin.dart';
import 'package:video_player/video_player.dart';

part 'controller.dart';

part 'view.dart';

class ProductDetailPage extends YPage {
  ProductDetailPage(this.spuId);

  String spuId;
  ProductDetailModel? model;

  bool isTypeShowGrid = false;
  bool isSaveLoading = false;
  int page_assets = 0;
  PageController pageController = PageController();
  ChewieController? chewieController;
  VideoPlayerController? videoController;
  bool isPlaying = false;

  @override
  void yOnCreate() {
    controller_initData();
    yBroadcast_register(IFinal.Broadcasts.refreshProductDetail, (map) {
      model?.count_carts = map!["count_carts"];
      setState(() {});
    });
  }

  @override
  void yOnDestory() {
    chewieController?.pause();
    videoController?.pause();
    videoController?.dispose();
    chewieController?.dispose();
  }

  @override
  Widget yBuild(BuildContext context) {
    return Container(
      color: IFinal.Colors.pageBG,
      child: Column(
        children: [
          view_topBar(),
          Expanded(
            child: model == null
                ? MyLoader()
                : Column(
                    children: [
                      Expanded(
                        child: MyScrollView(
                          children: [
                            view_banner(),
                            view_info(),
                            view_select(),
                            view_reply(),
                            view_detail(),
                          ],
                        ),
                      ),
                      view_bottom(),
                    ],
                  ),
          ),
        ],
      ),
    );
  }
}
